package com.woshua.vptabmodel.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.woshua.vptabmodel.R;

/**
 * @author Steven.zhao
 * email:hongtu.zhao@goodwinsoft.net
 * date:2019/7/20
 * desc:
 */
public class SplashFragment extends Fragment {

    private int resId;

    private static final String BUNDLE_RES_ID="bundle_res_id";

    public static SplashFragment newInstance(int resId)
    {
        Bundle bundle=new Bundle();
        bundle.putInt(BUNDLE_RES_ID,resId);
        SplashFragment splashFragment=new SplashFragment();
        splashFragment.setArguments(bundle);
        return splashFragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_splash,container,false);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final Bundle arguments = getArguments();
        if(arguments!=null)
        {
            resId=arguments.getInt(BUNDLE_RES_ID);
        }
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        ImageView ivSplash = view.findViewById(R.id.ivSplash);
        ivSplash.setImageResource(resId);
    }
}
